package com.vista.questionnaire.domain;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.*;
import javax.validation.constraints.*;

import java.io.Serializable;
import java.util.Objects;

import com.vista.questionnaire.domain.enumeration.QuestionEnum;
import org.springframework.util.StringUtils;

/**
 * A Question.
 */
@Entity
@Table(name = "question")
//@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Question implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @NotNull
    @Column(name = "name", unique = true)
    private String name;

    @NotNull
    @Enumerated(EnumType.STRING)
    @Column(name = "jhi_type", nullable = false)
    private QuestionEnum type;

    @Column(name = "y")
    private String y;

    private String documentID;

    @NotNull
    @Lob
    @Column(name = "content", columnDefinition = "TEXT", nullable = false)
    private String content;


    private int indexInExamination;
//    @ManyToOne
//    @JoinColumn(name = "examination")
//    private Examination examination;

    // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove


    public String getDocumentID() {
        return documentID;
    }

    public void setDocumentID(String documentID) {
        this.documentID = documentID;
    }

    public int getIndexInExamination() {
        return indexInExamination;
    }

    public void setIndexInExamination(int indexInExamination) {
        this.indexInExamination = indexInExamination;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public Question name(String name) {
        this.name = name;
        return this;
    }

    public String getY() {
        return y;
    }

    public void setY(String y) {
        this.y = y;
    }

    public void setName(String name) {
        this.name = name;
    }

    public QuestionEnum getType() {
        return type;
    }

    public Question type(QuestionEnum type) {
        this.type = type;
        return this;
    }

    public void setType(QuestionEnum type) {
        this.type = type;
    }

    public String getContent() {
        return content;
    }

    public Question content(String content) {
        this.content = content;
        return this;
    }

    public void setContent(String content) {
        this.content = content;
    }

//    public Examination getExamination() {
//        return examination;
//    }
//
//    public Question examination(Examination examination) {
//        this.examination = examination;
//        return this;
//    }
//
//    public void setExamination(Examination examination) {
//        this.examination = examination;
//    }
    // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Question question = (Question) o;
        if (question.getId() == null || getId() == null) {
            return false;
        }
        return Objects.equals(getId(), question.getId());
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(getId());
    }

    @Override
    public String toString() {
        return "Question{" +
            "id=" + getId() +
            ", name='" + getName() + "'" +
            ", type='" + getType() + "'" +
            ", content='" + getContent() + "'" +
            "}";
    }
}
